import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: resolve => require(['@/views/login.vue'], resolve)
  },
  {
    path: '/admin',
    component: resolve => require(['@/views/login.vue'], resolve)
  },
  {
    path: '/deskTop',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
	children:[
		{
		    path: 'home',
		    component: resolve => require(['@/views/deskTop/home.vue'], resolve),
			meta:{
				keepAlive:false
			}
		}
	]
  },
  //系统管理
  {
    path: '/system',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'usersys',
  		    component: resolve => require(['@/views/system/usersys.vue'], resolve),
			meta:{
				keepAlive:false
			}
  		},
		{
		    path: 'post',
		    component: resolve => require(['@/views/system/post.vue'], resolve),
			meta:{
				keepAlive:false
			}
		}
  	]
  },
  //基础信息
  {
    path: '/basicinfo',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'goodsSys',
  		    component: resolve => require(['@/views/basicinfo/goodsSys.vue'], resolve),
			meta:{
				keepAlive:true
			}
  		},
		{
		    path: 'customer',
		    component: resolve => require(['@/views/basicinfo/customer.vue'], resolve),
			meta:{
				keepAlive:false
			}
		},
		{
		    path: 'accountInfo',
		    component: resolve => require(['@/views/basicinfo/accountInfo.vue'], resolve),
			meta:{
				keepAlive:false
			}
		}
  	]
  },
  //采购管理
  {
    path: '/buyerSys',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'buyerInfo',
  		    component: resolve => require(['@/views/buyerSys/buyerInfo.vue'], resolve),
			meta:{
				keepAlive:true
			}
  		},
		{
		    path: 'buyerReturn',
		    component: resolve => require(['@/views/buyerSys/buyerReturn.vue'], resolve),
			meta:{
				keepAlive:true
			}
		},
		{
		    path: 'buyerDayInfo',
		    component: resolve => require(['@/views/buyerSys/buyerDayInfo.vue'], resolve),
			meta:{
				keepAlive:false
			}
		},
		{
		    path: 'codeSys',
		    component: resolve => require(['@/views/buyerSys/codeSys.vue'], resolve),
			meta:{
				keepAlive:false
			}
		},
		{
		    path: 'importData',
		    component: resolve => require(['@/views/buyerSys/importData.vue'], resolve),
			meta:{
				keepAlive:false
			}
		}
  	]
  },
  //库存管理
  {
    path: '/inventorySys',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
		{
		    path: 'inventoryGoods',
		    component: resolve => require(['@/views/inventorySys/inventoryGoods.vue'], resolve),
			meta:{
				keepAlive:false
			}
		},
  		{
  		    path: 'inventoryInfo',
  		    component: resolve => require(['@/views/inventorySys/inventoryInfo.vue'], resolve),
  			meta:{
  				keepAlive:false
  			}
  		},
		{
		    path: 'supplierInventoryInfo',
		    component: resolve => require(['@/views/inventorySys/supplierInventoryInfo.vue'], resolve),
			meta:{
				keepAlive:false
			}
		},
		{
		    path: 'codeTrace',
		    component: resolve => require(['@/views/inventorySys/codeTrace.vue'], resolve),
			meta:{
				keepAlive:false
			}
		},
		{
		    path: 'statusSys',
		    component: resolve => require(['@/views/inventorySys/statusSys.vue'], resolve),
			meta:{
				keepAlive:false
			}
		}
  	]
  },
  //批发管理
  {
    path: '/wholesalerSys',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'wholesaler',
  		    component: resolve => require(['@/views/wholesalerSys/wholesaler.vue'], resolve),
  			meta:{
  				keepAlive:false
  			}
  		},
		{
		    path: 'wholesalerDay',
		    component: resolve => require(['@/views/wholesalerSys/wholesalerDay.vue'], resolve),
			meta:{
				keepAlive:false
			}
		},
		{
		    path: 'wholesalerReturn',
		    component: resolve => require(['@/views/wholesalerSys/wholesalerReturn.vue'], resolve),
			meta:{
				keepAlive:false
			}
		},
		{
		    path: 'importData',
		    component: resolve => require(['@/views/wholesalerSys/importData.vue'], resolve),
			meta:{
				keepAlive:false
			}
		}
  	]
  },
  //利润核算
  {
    path: '/profitCalculation',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'profitCalculationInfo',
  		    component: resolve => require(['@/views/profitCalculation/profitCalculationInfo.vue'], resolve),
  			meta:{
  				keepAlive:false
  			}
  		}
  	]
  },
  //结算管理
  {
    path: '/settlementSys',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'settlementPut',
  		    component: resolve => require(['@/views/settlementSys/settlementPut.vue'], resolve),
  			meta:{
  				keepAlive:false
  			}
  		},
		{
		    path: 'settlementPay',
		    component: resolve => require(['@/views/settlementSys/settlementPay.vue'], resolve),
			meta:{
				keepAlive:false
			}
		},
		{
		    path: 'putAmount',
		    component: resolve => require(['@/views/settlementSys/putAmount.vue'], resolve),
			meta:{
				keepAlive:false
			}
		},
		{
		    path: 'payAmount',
		    component: resolve => require(['@/views/settlementSys/payAmount.vue'], resolve),
			meta:{
				keepAlive:false
			}
		},
		{
		    path: 'batchPut',
		    component: resolve => require(['@/views/settlementSys/batchPut.vue'], resolve),
			meta:{
				keepAlive:false
			}
		}
  	]
  },
  //结算明细
  {
    path: '/settlementDetail',
    component: resolve => require(['@/views/deskTop/deskTop.vue'], resolve),
  	children:[
  		{
  		    path: 'payInfo',
  		    component: resolve => require(['@/views/settlementDetail/payInfo.vue'], resolve),
  			meta:{
  				keepAlive:false
  			}
  		},
		{
		    path: 'notPayInfo',
		    component: resolve => require(['@/views/settlementDetail/notPayInfo.vue'], resolve),
			meta:{
				keepAlive:false
			}
		},
		{
		    path: 'putInfo',
		    component: resolve => require(['@/views/settlementDetail/putInfo.vue'], resolve),
			meta:{
				keepAlive:false
			}
		},
		{
		    path: 'notPutInfo',
		    component: resolve => require(['@/views/settlementDetail/notPutInfo.vue'], resolve),
			meta:{
				keepAlive:false
			}
		}
  	]
  },
]

// 解决报错
const originalPush = VueRouter.prototype.push;
const originalReplace = VueRouter.prototype.replace;
// push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalPush.call(this, location, onResolve, onReject);
  return originalPush.call(this, location).catch(err => err);
};
// replace
VueRouter.prototype.replace = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalReplace.call(this, location, onResolve, onReject);
  return originalReplace.call(this, location).catch(err => err);
};




const router = new VueRouter({
  mode: 'hash',
  routes
})

export default router
